<script th:inline="javascript">
    /*<![CDATA[*/

    function del(event, element) {
        event.preventDefault();

        var _goodsId = $(element).attr("href").split("_")[0];
        var _creditGoodsId = $(element).attr("href").split("_")[1];
        var _page = $(element).attr("href").split("_")[2];
        var _viewState = $(element).attr("href").split("_")[3];
        var data = {goodsId: _goodsId, creditGoodsId: _creditGoodsId, page: _page,viewState:_viewState};
        $.ajax({
          url: "/promotion/creditgoodsgoods/ajaxDelete",
          cache: false,
          type:"post",
          data:data,
          success:function(result) {		//回调函数，result，返回值
              $("#div_goods_grid").html(result);
          }
        });

    }

    /*]]>*/
</script>

<table layout:fragment="goods_table" class="table table-striped table-bordered  table-advance table-hover" id="goods_grid" onload="myfunction()">
<thead>
	<tr>
		<th>商品名称</th>
        <th>货号</th>
        <th>价格</th>
		<th>限购数量</th>
		<th>积分值</th>
		<th th:if="${creditGoods.creditType.description} == '积分加现金购'">现金</th>
		<!--<th>是否积分好礼</th>-->
		<th>是否可兑换</th>
		<th>操作</th>
	</tr>
</thead>	
<tbody>
	<tr class="odd gradeX" th:each="data : ${goodsPage}">
		<td th:text="${data.name}">
			 
		</td>
        <td th:text="${data.goodsSN}">

        </td>
         <td th:text="${data.shopPrice}">

        </td>
		<td th:unless="${data.creditGoodsGoods}">
			 <input type="text" style="width:140px;float:left;margin-right:8px;" placeholder="限购数量"  th:id="@{'limitNumber'+${data.id}}" class="form-control" />
		</td>
        <td th:if="${data.creditGoodsGoods}" th:text="${data.creditGoodsGoods.limitNumber}">

		</td>
		<td th:unless="${data.creditGoodsGoods}">
			 <input type="text" style="width:140px;float:left;margin-right:8px;" placeholder="积分值"  th:id="@{'credit'+${data.id}}" class="form-control" />
		</td>
        <td th:if="${data.creditGoodsGoods}" th:text="${data.creditGoodsGoods.credit}">

		</td>
        <div th:if="${creditGoods.creditType.description} == '积分加现金购'">
            <td th:unless="${data.creditGoodsGoods}">
			    <input type="text" style="width:140px;float:left;margin-right:8px;" placeholder="现金"  th:id="@{'money'+${data.id}}" class="form-control" />
		    </td>
            <td th:if="${data.creditGoodsGoods}" th:text="${data.creditGoodsGoods.money}">

		    </td>
        </div>
		<!--<td>
			 <input type="checkbox" placeholder="是否积分好礼"  th:id="@{'creditType'+${data.id}}" class="form-control" th:value="1"/>
		</td>-->
		<td th:unless="${data.creditGoodsGoods}">
			 <input type="checkbox" placeholder="是否可兑换"  th:id="@{'isExchange'+${data.id}}" class="form-control" checked="checked" th:value="1"/>
		</td>
        <td th:if="${data.creditGoodsGoods}">
            <span  class="tagsinput border-striped">
                <span th:if="${data.creditGoodsGoods.isExchange} == 0" class='badge badge-danger'>
                    <span th:text="否"></span>
                </span>
                <span th:if="${data.creditGoodsGoods.isExchange} == 1" class='badge badge-success'>
                    <span th:text="是"></span>
                </span>
            </span>
		</td>
		<td th:unless="${data.creditGoodsGoods}">
			 <a href="#"  th:href="${data.id}+'_'+${creditGoodsId}+'_'+${goodsPage.number}" th:attr="id=${'link_addgoods_'+dataStat.index},name=${'link_addgoods_'+dataStat.index}" class="btn default btn-xs purple" style="margin-top:7px;" onclick="add(event,this);"><i class="fa fa-plus"></i>添加</a>
		</td>
        <td th:if="${data.creditGoodsGoods}">
			 <!--<a href="#" th:href="${data.creditGoodsGoods.limitNumber}+'_'+${data.creditGoodsGoods.credit}+'_'+${data.creditGoodsGoods.money}+'_'+${data.creditGoodsGoods.isExchange}+'_'+${data.id}+'_'+${dataStat.index}+'_'+${creditGoodsId}" th:attr="id=${'link_addgoods_'+dataStat.index},name=${'link_addgoods_'+dataStat.index}" class="btn default btn-xs purple" style="margin-top:7px;" onclick="edit(event,this);"><i class="fa fa-edit"></i>编辑</a>-->
            <a href="#" th:href="${data.id}+'_'+${creditGoodsId}+'_'+${goodsPage.number}+'_'+${viewState}" th:attr="id=${'link_deletegoods_'+dataStat.index},name=${'link_deletegoods_'+dataStat.index}" class="btn default btn-xs purple" style="margin-top:7px;" onclick="del(event,this);"><i class="fa fa-minus"></i>删除</a>
		</td>
	</tr>
 	</tbody>
</table>

<div th:include="page_footer" th:with="viewState=${viewState},url=${'/promotion/creditgoodsgoods/list/'+creditGoodsId+'/'},pageContext=${goodsPage}"></div>